home *** CD-ROM | disk | FTP | other *** search
- Path: newsbf02.news.aol.com!not-for-mail
- From: jasoncone@aol.com (Jason Cone)
- Newsgroups: comp.lang.c++
- Subject: DLL Trouble
- Date: 28 Jan 1996 23:29:54 -0500
- Organization: America Online, Inc. (1-800-827-6364)
- Sender: root@newsbf02.news.aol.com
- Message-ID: <4ehig2$7d3@newsbf02.news.aol.com>
- Reply-To: jasoncone@aol.com (Jason Cone)
- NNTP-Posting-Host: newsbf02.mail.aol.com
-
- I am trying to use Turbo C++ Visual Edition for Windows to write a DLL
- which contains a single exportable function called rolldice. I want to
- call this function from within a Paradox for Windows 4.5 form.
-
- In Paradox, I have used the form's USES window to specify the DLL as
- follows:
-
- Uses DICE ; dice.dll
- rolldice(sides CWORD, qty CWORD) CWORD
- endUses
-
- Paradox calls the function like this:
-
- method pushButton(var eventInfo Event)
- var
- i, rolled SmallInt
- endVar
-
- for i from 1 to 6
- rolled = rolldice(6,3) ; <--- CALLED HERE
- switch
- case i = 1 : STR.value = rolled
- case i = 2 : INT.value = rolled
- case i = 3 : WIS.value = rolled
- case i = 4 : DEX.value = rolled
- case i = 5 : CON.value = rolled
- case i = 6 : CHA.value = rolled
- endSwitch
- endFor
- endmethod
-
-
-
- Following is the C/C++ code for the DLL:
-
- #include <stdlib.h>
- #include <time.h>
- #include <windows.h>
-
- int far pascal _export rolldice(int, int);
-
- int far pascal _export rolldice(int sides, int qty)
- {
- int result = 0;
-
- for (int i = 0; i < qty; i++)
- result += (random(sides) + 1);
- return result;
- }
-
- int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg, WORD cbHeapSize,
- LPSTR lpCmdLine);
-
- int FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSeg, WORD cbHeapSize,
- LPSTR lpCmdLine){
- return 1;
- }
-
- I compile this code as a DLL using the Large Memory model, Explicit
- Functions Exported, targeted for Windows 3.1 or greater, Static Runtime
- Library. It compiles fine, giving me warnings that the four LibMain
- parameters are never used.
-
- However, when I try to run my Paradox form, I get an error which says that
- "This form references external procedures or DLLs which could not be
- found." I believe the problem is locating the "external procedures" not
- the DLL itself, as I've tried moving the DLL around between Windows,
- Windows\System, and the form's working directory.
-
- I can't figure out what I'm doing wrong.
-
- Oh, I'm running Windows 95, if that makes any difference.
-
- Please email any response to JasonCone@aol.com
- Thanks!
-